package com.mybatisflex.generator;

import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;
import com.zaxxer.hikari.HikariDataSource;

public class MybatisFlexGenerator {
    public static void main(String[] args) {
        //配置数据源
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl("jdbc:oracle:thin:@192.168.1.18:1521:orcl");
        dataSource.setUsername("maige");
        dataSource.setPassword("5sl84L0fVFxpVt");

        GlobalConfig globalConfig = new GlobalConfig();
        globalConfig.getPackageConfig().setSourceDir("E:\\gits\\mybatisflex\\src\\main")
                .setBasePackage("com.test").setMapperXmlPath("E:\\gits\\mybatisflex\\src\\resources");
        globalConfig.getStrategyConfig()
                .setGenerateTable("T_AFTER_SALE")
                .setTablePrefix("T_","t_");

        globalConfig.getEntityConfig()
                .setWithLombok(Boolean.TRUE)
                .setOverwriteEnable(Boolean.TRUE)
                .setColumnCommentEnable(Boolean.TRUE);

        globalConfig.getMapperConfig()
                .setOverwriteEnable(Boolean.TRUE)
                .setClassSuffix("Mapper");

        globalConfig.getMapperXmlConfig()
                .setFileSuffix("Mapper")
                .setOverwriteEnable(Boolean.TRUE);

        globalConfig.enableEntity();
        globalConfig.enableMapperXml();
        globalConfig.enableMapper();
        globalConfig.enableService();
        globalConfig.enableServiceImpl();

        Generator generator = new Generator(dataSource, globalConfig);
        generator.generate();

    }
}
